home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Devices / CDROMDriveCheck / CDROMDriveCheck.c next >
Encoding:
C/C++ Source or Header  |  1995-02-07  |  1.4 KB  |  62 lines  |  [TEXT/MPS ]

  1. /*
  2. File: CDROMDriveCheck.c
  3.  
  4. What's this?
  5. An MPW c tool that checks to see which SCSI IDs are AppleCD SC drives.  It
  6. makes a status call(97) to the AppleCD SC driver (only works with this 
  7. driver).  On exit from the status call, the byte at csParam+1 contains a 
  8. bit field with bits 7 - 0 corresponding to SCSI IDs 7 - 0.  That is, a 
  9. value of 10000010 means there are two AppleCD SCs attached, with SCSI 
  10. IDs 7 and 1.
  11.  
  12. Code notes:
  13. As the Blue Öyster Cult says, I'm making a career of evil:  the refnum is 
  14. hard-coded, which would cause Clarus to commence to bitin' on my kneecaps 
  15. (dogcows aren't very tall) were s/he to find out.
  16.  
  17. Further references:
  18. Apple CD SC™ Developers Guide, Revised Edition, Macintosh CD-ROM device 
  19. driver status calls section.   It's available from APDA.
  20.  
  21. Mark Baumwell 4/1/92
  22.  
  23. */
  24.  
  25. #include    <types.h>
  26. #include    <stdio.h>
  27. #include    <files.h>
  28. #include    <osutils.h>
  29. #include    <strings.h>
  30. #include     <devices.h>
  31. #include    <sane.h>
  32.  
  33. main()
  34.  
  35. {
  36.    CntrlParam
  37.    pb;
  38.  
  39.    OSErr
  40.    err;
  41.    
  42.    /*Debugger();*/
  43.    
  44.    pb.ioCompletion = nil;
  45.    pb.ioVRefNum = 1;
  46.    pb.ioCRefNum = -39; /*Don't hard code refnum!!!*/
  47.    pb.ioNamePtr = nil;
  48.    pb.csCode = 97; // checks bit for a CD ROM
  49.  
  50.    err = PBStatus ((ParmBlkPtr) &pb, false);
  51.    if (err == noErr)
  52.    {
  53.    char byte2; /*in c, char is an 8 bit value*/
  54.    byte2 = ((char*) pb.csParam)[1];
  55.    printf ("the csParam (in decimal) = %i\n",(short)byte2);
  56.    }
  57.    else
  58.    {
  59.    printf ("error = %i\n",err);
  60.    }
  61. }
  62.